﻿namespace BasicParts
{
    public struct Rectangle
    {
        public int X, Y, Width, Height;

        //public Rectangle() { X = Y = Width = Height = 0; }
        public Rectangle(int x, int y, int width, int height)
        { X = x; Y = y; Width = width; Height = height; }


        public bool Intersects(Rectangle rect)
        {
            return ((X <= rect.X && X + Width >= rect.X) ||
                   (rect.X <= X && rect.X + rect.Width >= X)) &&
                   ((Y <= rect.Y && Y + Width >= rect.Y) ||
                   (rect.Y <= Y && rect.Y + rect.Width >= Y));
        }

        public Vector2 Size
        {
            get { return new Vector2(Width, Height); }
            set { Width = (int)value.X; Height = (int)value.Y; }
        }
    }
}
